package com.fanketly.routes

import com.fanketly.models.musicInfoStorage
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*

fun Route.musicRouting() {
    route("/musicInfo") {
        get {
            val mood = call.parameters["mood"] ?: return@get call.respondText(
                "没有传入心情",
                status = HttpStatusCode.BadRequest
            )
            val songInfo = musicInfoStorage.find { it.mood == mood } ?: return@get call.respondText(
                "抱歉,没有${mood}的音乐",
                status = HttpStatusCode.NotFound
            )
            call.respond(songInfo)
        }
    }
}